<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class News_model extends MY_Model
{
    public function __construct()
    {
        parent::__construct();
    }

    public function getMyNewsList($fields = ' * ',$per_page, $limit)
    {
    	
    	$limit = " limit {$per_page},{$limit}";

        $sql = "SELECT {$fields} FROM tr_news WHERE isDel=0  ORDER BY addtime DESC {$limit} ";

        $query = $this->db->query($sql);
        $result =$query->result_array();
        return $result;
    }


    public function getMyNewsListCnt()
    {
        
        $sql = "SELECT newsID FROM tr_news WHERE isDel=0  ORDER BY addtime DESC";
        $query = $this->db->query($sql);
        return $query->num_rows();
    }


    public function getDetail($fields = ' * ',$id = 0)
    {
    	$sql = "SELECT {$fields} FROM tr_news WHERE isDel=0 AND newsID={$id}  ORDER BY addtime DESC";
    	$query = $this->db->query($sql);
    	return $query->row_array();
    }
    
}

/* End of file Index_model.php */
/* Location: ./application/models/index_model.php */